const http = require('http');
const fs = require('fs');
const {httpReadFile} = require('./utils/file-util')
const server = http.createServer();

server.listen(3308, function () {
    console.log("留言板服务启动成功~");
})


server.on('request', function (request, response) {
    console.log(request.url);
    if (request.url === '/') {
        httpReadFile('./views/index.html',response)
    }
    // 允许用户
    else if (request.url.startsWith('/node_modules')) {
        httpReadFile("."+request.url,response)
    }
    else {
        httpReadFile('./views/error.html',response)
    }
})


